<?php
/**
 * 商品SKU
 * Author: hades
 * DateTime: 2020/5/16 17:42
 */

namespace App\Controller\admin;

use App\Model\Goods;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\Middleware;

/**
 * Class GoodsSkuController
 * @package App\Controller\admin
 * @Controller(prefix="a/goods/sku")
 * @Middleware(\App\Middleware\AdminMiddleware::class)
 */
class GoodsSkuController extends AdminBase {

    public function getInfo() {
        $gid = $this->get('gid');
        // 查询商品所属分类
        $cid = $this->getGoodsCid($gid);
        if ($cid == 0) {
            return error('商品不存在');
        }
        // 根据分类查属性

    }

    /**
     * 获取商品分类ID
     * @param $id
     * @return int
     */
    private function getGoodsCid($id) {
        return (int) Goods::query()->where('id', $id)->value('cid');
    }
}
